#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+10;
int f[N];
int main() {
    int n;
    int T = 0;
    while (cin >> n && n){
        string s; cin >> s;
        f[0] = f[1] = 0;
        for (int i = 1; i < s.size(); ++i) {
            int j = f[i];
            while (j && s[i] != s[j]) j = f[j];
            f[i+1] = s[i]==s[j]? j+1:0;
        }
        if(T) putchar('\n');
        printf("Test case #%d\n", ++T);
        for (int i = 0; i <= s.size(); ++i) {
            if(f[i] && i%(i-f[i])==0) printf("%d %d\n", i, i/(i-f[i]));
        }
    }
    return 0;
}